@dashincubator/base58check
Base58Check & WIF for Public Key Hash addresses and Private Keys
Usage
Can convert Public Key Hashes and Private Keys between Hex, Base58Check, and
WIF.
CLI
npm install -g @dashincubator/base58check
base58check XfMBLVNyzPxEELVUUsg7AJAHWKiV9do7Pj
base58check 3320974335dc4888b501e965fe5ff3c4421c09c4 4c
Node.js
npm install --save @dashincubator/base58check
let Base58Check = require("base58check").Base58Check;
let b58c = Base58Check.create();
let pkh = `XfMBLVNyzPxEELVUUsg7AJAHWKiV9do7Pj`;
let parts = await b58c.verify(pkh);
let wif = "XE7KZ98bqtbomihJqkuRzi6DusLAXegQFBmnATDAUVSCxtcbigHb";
let parts = await b58c.verify(wif);
let xpub = `xpub6EtdcAi4VMbZRDgSaA1WmrqB8asuswgz1toia3YULccxyJXYqdxwqFgeEexVxr8ytJPHZYTrhbYJjqaFumih45awabyaHwUmCvXbGf7sujG`;
let parts = await b58c.decode(xpub);
let xprv = `xprvA1WUDWFxdE5UGW1XNTnkZnd3K6bdidZBTtzvtEQziBpS3N8tajC4QKyRLmas7DK4HXK76wSXgMV1uV6RbKyM5f4uu1VmguEhAqvzQwr2mrC`;
let parts = await b58c.decode(xprv);
Options
You can enforce your instance of Base58Check to verify and generate a particular
version of coin, or to use a different Base58 dictionary.
Base58Check.create({
pubKeyHashVersion: `4c`,
privateKeyVersion: `cc`,
dictionary: `123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`,
});
Base58Check Summary
- 1 byte Version
- 16 bytes "Compressed" Public Key Hash
- 4 bytes Checksum
XxJ7EZT2VyJ821LeAzoT9aDDSuempCikd3
4c ed060e9316ea54396038b7ef703c0616025ddc55 03368b2e
{
version: '4c',
pubKeyHash: 'ed060e9316ea54396038b7ef703c0616025ddc55',
check: '03368b2e'
}
WIF (Wallet Import Format)
- 1 byte Version
- 32 bytes Private Key
- 1 byte (Optional) Has Compressed Public Key
- 4 bytes Checksum
XJxvA5cC4zi3DYeMVUgHunF3nt5UajjXAvJaHnZRMunPNjyKmGfB
cc e51245e19bfc59800445c91d6623a8225f5e521d339fca2a5bbe71fb973dac0f (01) 90d16dc2
{
version: 'cc',
privateKey: 'e51245e19bfc59800445c91d6623a8225f5e521d339fca2a5bbe71fb973dac0f',
compressed: true,
check: '90d16dc2'
}